#include "textquery.h"

TextQuery::TextQuery(std::ifstream& infile)
    //:file(new std::vector<std::string>)
    :file(std::make_shared<std::vector<std::string>>())
{
    std::string text;
    while(getline(infile, text)){
        file->push_back(text);
        int n = file->size() - 1;   //行号
        std::istringstream line(text);
        std::string world;
        while (line >> world) {
            auto &lines = wm[world];
            if (!lines) {
                lines.reset(new std::set<line_no>);
                lines->insert(n);
            }
        }
    }
}
